package org.lboot.flow.module.define.history;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.Hibernate;
import org.lboot.jpa.entity.BaseEntity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Objects;

/**
 * @author kindear
 * 流程定义历史记录
 */
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
@Table(name = "flow_define_history")
@ApiModel(value = "流程定义历史记录")
public class FlowDefineHistory extends BaseEntity implements Serializable {
    @ApiModelProperty("流程定义编码")
    @Column(name = "flow_code")
    String flowCode;

    @ApiModelProperty("流程名称")
    @Column(name = "flow_name")
    String flowName;

    @ApiModelProperty("流程描述")
    @Column(name = "description",length = 512)
    String description;


    @ApiModelProperty(value = "流程定义类型")
    @Column(name = "flow_define_type")
    String flowDefineType;


    @ApiModelProperty(value = "流程定义",notes = "JSON字符串")
    @Column(name = "flow_define",columnDefinition = "TEXT")
    String flowDefine;

    @ApiModelProperty(value = "表单定义",notes = "JSON字符串")
    @Column(name = "flow_widgets",columnDefinition = "TEXT")
    String flowWidgets;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
        FlowDefineHistory history = (FlowDefineHistory) o;
        return id != null && Objects.equals(id, history.id);
    }

    @Override
    public int hashCode() {
        return getClass().hashCode();
    }
}
